﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_Admin : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"] != null && Session["fullname"] != null)
        {
            lblUsername.Text = "Hello, " + Session["fullname"].ToString();
            btnLogout.Visible = true;
        }
        else if (Request.Cookies["username"] != null && Request.Cookies["fullname"] != null)
        {
            lblUsername.Text = "Hello, " + Request.Cookies["fullname"].Value;
        }
        else
        {
            lblUsername.Text = "";
            btnLogout.Visible = false;
        }
    }
    protected void btnLogout_Click(object sender, EventArgs e)
    {
        //if (Request.Cookies["username"] != null)
        //{
        //    HttpCookie c = new HttpCookie("username", "a");
        //    c.Expires = DateTime.Now.AddDays(-15);
        //    Response.Cookies.Add(c);
        //    if (Session["username"] != null)
        //    {
        //        Session["username"] = null;
        //    }
        //}
        //else 
            if (Session["username"] != null)
            {
                Session["username"] = null;
            }
        Response.Redirect("Login.aspx"); 
    }
    protected void lblUsername_Click(object sender, EventArgs e)
    {
        Response.Redirect("PersonInfo.aspx"); 
    }
}
